package avicit.bdp.dms.perm.dto;

import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2022-11-09
 * @类说明：DataPermDTO
 * @修改记录：
 * @注意事项：
 * @主要功能：行权限DTO
 */
@ApiModel(value = "DataPermDTO", description = "行权限DTO")
@Table(name = "bdp_dms_perm_data")
public class DataPermDTO extends BasePermDTO {
    private static final long serialVersionUID = 1L;

    /**
     * 分类ID
     */
    @LogField
    @ApiModelProperty(value = "分类ID")
    @FieldRemark(column = "type_id", field = "typeId", name = "分类ID")
    @Column(name = "type_id")
    private String typeId;

    @Transient
    private String typeName;

    /**
     * 模型表ID
     */
    @LogField
    @ApiModelProperty(value = "模型表ID")
    @FieldRemark(column = "table_id", field = "tableId", name = "模型表ID")
    @Column(name = "table_id")
    private String tableId;

    /**
     * 模型表名称
     */
    @LogField
    @ApiModelProperty(value = "模型表名称")
    @FieldRemark(column = "table_name", field = "tableName", name = "模型表名称")
    @Column(name = "table_name")
    private String tableName;

    /**
     * 模型中文名称
     */
    @LogField
    @ApiModelProperty(value = "模型中文名称")
    @FieldRemark(column = "table_cn_name", field = "tableCnName", name = "模型中文名称")
    @Column(name = "table_cn_name")
    private String tableCnName;

    /**
     * 数据源类型
     */
    @LogField
    @ApiModelProperty(value = "数据源类型")
    @FieldRemark(column = "datasource_type", field = "datasourceType", name = "数据源类型")
    @Column(name = "datasource_type")
    private String datasourceType;

    /**
     * 字段列表
     */
    @LogField
    @ApiModelProperty(value = "字段列表")
    @FieldRemark(column = "columns", field = "columns", name = "字段列表")
    @Column(name = "columns")
    private String columns;

    @Transient
    private List<String> columnList;

    /**
     * 自定义where条件(SQL)
     */
    @LogField
    @ApiModelProperty(value = "自定义where条件")
    @FieldRemark(column = "custom_where_cond", field = "custom_where_cond", name = "自定义where条件")
    @Column(name = "custom_where_cond")
    private String customWhereCond;

    /**
     * 角色名称
     */
    @Transient
    private String roleName;

    /**
     * 预览SQL
     */
    @Transient
    private String sql;

    public String getTypeId() {
        return typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getTableId() {
        return tableId;
    }

    public void setTableId(String tableId) {
        this.tableId = tableId;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getTableCnName() {
        return tableCnName;
    }

    public void setTableCnName(String tableCnName) {
        this.tableCnName = tableCnName;
    }

    public String getDatasourceType() {
        return datasourceType;
    }

    public void setDatasourceType(String datasourceType) {
        this.datasourceType = datasourceType;
    }

    public String getColumns() {
        return columns;
    }

    public void setColumns(String columns) {
        this.columns = columns;
    }

    public List<String> getColumnList() {
        return columnList;
    }

    public void setColumnList(List<String> columnList) {
        this.columnList = columnList;
    }

    public String getCustomWhereCond() {
        return customWhereCond;
    }

    public void setCustomWhereCond(String customWhereCond) {
        this.customWhereCond = customWhereCond;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "数据授权模块";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "数据授权";
        } else {
            return super.logTitle;
        }
    }
}
